<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>文章列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all"/>
    <link rel="stylesheet" href="{:_SKIN}/shadmin/v3/css/news.css" media="all"/>
    {:jq()}
</head>

<body class="childrenBody">
<blockquote class="layui-elem-quote news_search">
    <div class="layui-inline">
        <div class="layui-input-inline">
            <input type="text" value="" placeholder="请输入关键字" class="layui-input search_input" >
        </div>
        <a class="layui-btn search_btn">查询</a>
    </div>
    <div class="layui-inline">
        <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:url('news',['listid'=>input('listid')])}">添加文章</a>
    </div>
    
    
    <div class="layui-inline">
        <a class="layui-btn layui-btn-danger batchDel">批量删除</a>
    </div>
    <div class="layui-inline">
        <div class="layui-form-mid layui-word-aux">　共找到 {$num} 条</div>
    </div>
</blockquote>
<div class="layui-form news_list">
    <table class="layui-table">
        <colgroup>
            <col width="50">
            <col>
            <col width="9%">
            <col width="9%">
            <col width="9%">
            <col width="9%">
            <col width="9%">
            <col width="20%">
        </colgroup>
        <thead>
        <tr>
            <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose" id="allChoose"></th>
            <th style="text-align:left;">文章标题</th>
            <th>所属分类</th>

            <th>阅读量</th>
            <th>发布人</th>
            <th>审核</th>
            <th>发布时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody class="news_content">
        {volist name="list" id="v"}
        <tr id="d{$v.ID}">
            <td><input type="checkbox" name="checked" lay-skin="primary" lay-filter="choose">
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div>
            </td>
            <td align="left">{$v.Title}</td>
            <td>{$v.BusModel}</td>

            <td>{$v.PageNum}</td>
            <td>{$v.AccountName}</td>
           
         
            {eq name="v.State" value="3"}


            {eq name=":session('status')" value="管理员"}
          
            <td><input type="checkbox" name="show" lay-skin="switch" lay-text="通过|待审" lay-filter="isShow" data-id="{$v.ID}" checked=""></td>

             {else /}

              <td>已审核</td>
            
            {/eq}



            {else /}

            {eq name=":session('status')" value="管理员"}

            <td><input type="checkbox" name="show" lay-skin="switch" lay-text="通过|待审" lay-filter="isShow" data-id="{$v.ID}" ></td>
             {else /}

              <td><a class="layui-btn layui-btn-mini layui-btn-disabled">待审核</a></td>
            
            {/eq}

            {/eq}






            <td>{$v.addtime}</td>
            <td><a class="layui-btn layui-btn-mini news_edit" href="{:url('news',['id'=>$v['ID'],'listid'=>$v['BusModelID']])}"><i class="iconfont icon-edit"></i> 编辑</a>
            <a class="layui-btn layui-btn-normal layui-btn-mini news_collect v_news" data-url="{:url('weixin/news/news',['id'=>$v['ID']])}"><i class="layui-icon"></i> 预览</a>
                    <a
                    class="layui-btn layui-btn-danger layui-btn-mini news_del"  data-id="{$v.ID}"><i class="layui-icon"></i>
                删除</a></td>
        </tr>
        {/volist}
        </tbody>
    </table>
</div>

<div id="page">{$page}</div>

<style>
    .pagination { margin-left: 50px;}
    .pagination li { float: left; background: #34a8fe; color: #fff; margin-right:8px ; }
    .pagination li a,.pagination li span { color:#fff;padding: 8px 10px;display: block}
    .pagination .active  { background-color: #fe6738}

</style>
{:jq()}
{:layui()}
<script>


    //修改产品状态
    layui.form.on('switch(isShow)', function (data) {
        var id = $(data.elem).data('id');


        var key = data.elem.checked ? 3 : 4;

        $.post("{:url('dev/changnews')}", {id: id, key: key}, function (res) {

            if (res.code != 200) {

                panent.layer.alert('网络繁忙，请重试');

            }

        });


    });



  
    $(".v_news").click(function(){

        var url=$(this).data('url');

        layer.open({
            type: 2,
            title: '新闻预览',
            shadeClose: true,
            shade: 0.8,
            area: ['400px', '90%'],
            content: url //iframe的url
        });



    });


    $(".news_del").click(function(){
        var id=$(this).data('id');
        parent.layer.confirm("确定要删除该新闻吗？删除后不可恢复",function(){
              $("#d"+id).remove();

              parent.layer.msg('删除成功', {shift: 0, time: 1500}, function () {

                       
                    });


            $.post("{:url('dev/delnews')}",{id:id},function(res){

                if(res.code==200){


                   

                }else{

                    parent.layer.msg(res.msg);

                }

            });


        });


    });


</script>


</body>
</html>